﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Web.Services;
public partial class Admin_News : System.Web.UI.Page
{
    NewsController newsController = new NewsController();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

            grvNews.DataSource = newsController.GetAll();
            grvNews.DataBind();
            if (grvNews.Rows.Count > 0)
            {
                grvNews.UseAccessibleHeader = true;
                grvNews.HeaderRow.TableSection = TableRowSection.TableHeader;
            }
        }
    }
    [WebMethod]
    public static string deleteNews(int id)
    {
        NewsController newsController = new NewsController();
        if(newsController.Delete(id)>0)
        {
            return "Xóa tin tức thành công";
        }
        else
        {
            return "Xóa tin tức gặp lỗi";
        }
    }
}